// This is the skeleton code for the comparator class.
// You will need to change the return value of the
// operator() function to reflect the heuristic specified
// in the handout.  Feel free to add private methods to
// this class if it will help you perform the calculation.

#ifndef _COMPARE_H
#define _COMPARE_H
#include <iostream>
#include <cmath>
#include "Triangle.h"
#include "Edge.h"
#include "Point.h"

using namespace std;

class TriangleCompare {

public:
	//return true if the area of t1 is greater than area of t2
	bool operator() (Triangle* t1, Triangle* t2)
    {
		return (t1->getArea())>(t2->getArea());
    }
};


class EdgeCompare {
public:
	bool operator() (Edge* e1, Edge* e2){
		return hash(e1)>hash(e2);
	}
protected:
	int hash(Edge* e){

                static int PRIME = 2796203;
		int x1 = e->getPoint1()->getX();
		int y1 = e->getPoint1()->getY();
		int x2 = e->getPoint2()->getX();
		int y2 = e->getPoint2()->getY();
		
		return ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(x1+x2)*PRIME+y1+y2);
	}
};

class PointCompare {
public:
    bool operator() (Point* p1, Point* p2){
        if(p1->getX() != p2->getX())
        return (p1->getX() > p2->getX());
        else
        return (p1->getY() > p2->getY());
    }
};

#endif
